home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 103 / CD-ROM 103.iso / edu / martianwin / src / initSDL.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-08-11  |  992 b   |  37 lines

  1. #include<SDL/SDL.h>
  2. #include<SDL/SDL_mixer.h>
  3. SDL_Surface *screen;
  4.  
  5. #define screen_w 640
  6. #define screen_h 480
  7. #define screen_bpp 16
  8.  
  9. void initSDL()
  10. {
  11.     if((SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0))
  12.     {
  13.         fprintf(stderr,"Could not Initialize SDL.\nError: %s\n", SDL_GetError());
  14.         exit (-1);
  15.     }
  16.     SDL_Surface *icon;
  17.     icon=SDL_LoadBMP(DATADIR "/gfx/icon.bmp");
  18.     SDL_WM_SetIcon(icon, NULL);
  19.     screen = SDL_SetVideoMode(screen_w,screen_h,screen_bpp, SDL_DOUBLEBUF|SDL_HWSURFACE);
  20.     if (screen == NULL)
  21.     {
  22.         fprintf(stderr, "Can't set the video mode. Quitting.\nError; %s\n", SDL_GetError());
  23.         exit (1);
  24.     }
  25.     if(Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 2048) < 0)
  26.     {
  27.         fprintf(stderr,"Warning: Couldn't set 44100 Hz 16-bit audio\n: %s\n", SDL_GetError());
  28.     }
  29.  
  30.  
  31.  
  32.     SDL_ShowCursor(1);
  33.     SDL_WM_SetCaption("Martian memory", "Martian Memory");
  34.     fprintf(stderr,"System init Ok.\n");
  35.     fprintf(stderr,"   Entering game...\n");
  36. }
  37.